package com.huanshi.module.pms.controller;

import com.huanshi.common.CommonResult;
import com.huanshi.entity.PmsBrand;
import com.huanshi.service.PmsBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * 品牌Controller
 * 
 * @author huanshi
 * @date 2023-07-02
 */
@RestController
@RequestMapping("/api/pms/brand")
public class PmsBrandController {
    @Autowired
    private PmsBrandService brandService;

    /**
     * 查询品牌列表
     */
    @GetMapping("/list")
    public CommonResult list()
    {
        List<PmsBrand> list = brandService.list();
        return CommonResult.success(list);
    }

    /**
     * 获取品牌详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return CommonResult.success(brandService.getById(id));
    }

    /**
     * 新增品牌
     */
    @PostMapping
    public CommonResult add(@RequestBody PmsBrand brand)
    {
        return CommonResult.success(brandService.save(brand));
    }

    /**
     * 修改品牌
     */
    @PutMapping
    public CommonResult edit(@RequestBody PmsBrand brand)
    {
        return CommonResult.success(brandService.updateById(brand));
    }

    /**
     * 删除品牌
     */
	@DeleteMapping("/del/batch")
    public CommonResult remove(@RequestBody List<Integer> ids)
    {
        return CommonResult.success(brandService.removeByIds(ids));
    }
}
